/*
 * Decompiled with CFR 0.150.
 * 
 * Could not load the following classes:
 *  cn.hutool.core.util.ObjectUtil
 *  com.alibaba.fastjson.JSON
 *  de.felixroske.jfxsupport.FXMLController
 *  javafx.fxml.FXML
 *  javafx.fxml.Initializable
 *  javafx.scene.control.Alert
 *  javafx.scene.control.Alert$AlertType
 *  javafx.scene.control.Button
 *  javafx.scene.control.TextField
 *  javafx.scene.layout.Pane
 *  org.springframework.beans.factory.annotation.Autowired
 *  org.springframework.util.CollectionUtils
 *  org.springframework.util.StringUtils
 */
package com.gys.controller.payingBank;

import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON;
import com.gys.common.business.BankInfoUtil;
import com.gys.common.data.HttpJson;
import com.gys.common.util.CacheUtil;
import com.gys.controller.BaseController;
import com.gys.controller.payingBank.PayingBankController;
import com.gys.data.example.GetUserOutData;
import com.gys.data.payingBank.BankInfoInData;
import com.gys.data.payingBank.BankInfoOutData;
import de.felixroske.jfxsupport.FXMLController;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Alert;
import javafx.scene.control.Button;
import javafx.scene.control.TextField;
import javafx.scene.layout.Pane;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;

@FXMLController
public class EditBankInfoController
extends BaseController
implements Initializable {
    @FXML
    private TextField gsbsBankId;
    @FXML
    private Button editBtn;
    @FXML
    private Pane modelPane;
    @FXML
    private TextField gsbsBrId;
    @FXML
    private TextField gsbsBankName;
    @FXML
    private TextField gsbsBankAccount;
    @FXML
    private Button addBtn;
    @Autowired
    private PayingBankController payingBankController;

    public void initialize(URL location, ResourceBundle resources) {
        this.initResource();
    }

    public BankInfoOutData getSelectIndex() {
        BankInfoOutData outData = new BankInfoOutData();
        if (!CollectionUtils.isEmpty(this.payingBankController.getObservableTableList())) {
            for (BankInfoOutData i : this.payingBankController.getObservableTableList()) {
                if (!i.getCheckBox().isSelected().booleanValue()) continue;
                outData = i;
            }
        }
        return outData;
    }

    private void initResource() {
        BankInfoOutData outDataTemp = this.getSelectIndex();
        BankInfoOutData outData = new BankInfoOutData();
        BankInfoInData inData = new BankInfoInData();
        inData.setClientId(outDataTemp.getClientId());
        inData.setGsbsBankId(outDataTemp.getGsbsBankId());
        HttpJson rsp = BankInfoUtil.getBankInfo(inData);
        if (!rsp.isSuccess()) {
            Alert alert = this.createAlert(Alert.AlertType.INFORMATION, "\u63d0\u793a\u4fe1\u606f", rsp.getMsg());
            alert.showAndWait();
            return;
        }
        outData = (BankInfoOutData)JSON.parseObject((String)rsp.getMsg(), BankInfoOutData.class);
        if (ObjectUtil.isNotEmpty(outData)) {
            this.gsbsBrId.setText(outData.getGsbsBrId());
            this.gsbsBrId.setEditable(false);
            this.gsbsBankId.setText(outData.getGsbsBankId());
            this.gsbsBankId.setEditable(false);
            this.gsbsBankName.setText(outData.getGsbsBankName());
            this.gsbsBankAccount.setText(outData.getGsbsBankAccount());
        }
    }

    private void initPane() {
        this.gsbsBrId.clear();
        this.gsbsBankName.clear();
        this.gsbsBankAccount.clear();
    }

    @Override
    public void init() {
        if (ObjectUtil.isNotEmpty(this.editBtn)) {
            this.initPane();
            this.initResource();
        }
    }

    @FXML
    void editBankInfo() {
        String bankName = this.gsbsBankName.getText().trim();
        String bankAccount = this.gsbsBankAccount.getText().trim();
        String bankId = this.gsbsBankId.getText().trim();
        Alert alert = this.createAlert(Alert.AlertType.INFORMATION, "\u63d0\u793a\u4fe1\u606f", null);
        if (StringUtils.isEmpty(bankName)) {
            alert.setContentText("\u94f6\u884c\u540d\u79f0\u4e0d\u53ef\u4e3a\u7a7a");
            alert.showAndWait();
            return;
        }
        if (StringUtils.isEmpty(bankAccount)) {
            alert.setContentText("\u94f6\u884c\u8d26\u53f7\u4e0d\u53ef\u4e3a\u7a7a");
            alert.showAndWait();
            return;
        }
        BankInfoInData inData = new BankInfoInData();
        inData.setClientId(((GetUserOutData)CacheUtil.get("logInUser")).getClient());
        inData.setGsbsBankId(bankId);
        inData.setGsbsBankName(bankName);
        inData.setGsbsBankAccount(bankAccount);
        HttpJson rsp = BankInfoUtil.editBankInfo(inData);
        if (rsp.isSuccess()) {
            alert.setContentText("\u66f4\u65b0\u6210\u529f");
            alert.showAndWait();
            this.closeWindow();
            this.payingBankController.initTable();
        } else {
            alert.setContentText("\u8bf7\u4fee\u6539");
            alert.showAndWait();
        }
    }

    @FXML
    private void closeWindow() {
        this.modelPane.getScene().getWindow().hide();
    }

    public TextField getGsbsBankId() {
        return this.gsbsBankId;
    }

    public Button getEditBtn() {
        return this.editBtn;
    }

    public Pane getModelPane() {
        return this.modelPane;
    }

    public TextField getGsbsBrId() {
        return this.gsbsBrId;
    }

    public TextField getGsbsBankName() {
        return this.gsbsBankName;
    }

    public TextField getGsbsBankAccount() {
        return this.gsbsBankAccount;
    }

    public Button getAddBtn() {
        return this.addBtn;
    }

    public PayingBankController getPayingBankController() {
        return this.payingBankController;
    }

    public void setGsbsBankId(TextField gsbsBankId) {
        this.gsbsBankId = gsbsBankId;
    }

    public void setEditBtn(Button editBtn) {
        this.editBtn = editBtn;
    }

    public void setModelPane(Pane modelPane) {
        this.modelPane = modelPane;
    }

    public void setGsbsBrId(TextField gsbsBrId) {
        this.gsbsBrId = gsbsBrId;
    }

    public void setGsbsBankName(TextField gsbsBankName) {
        this.gsbsBankName = gsbsBankName;
    }

    public void setGsbsBankAccount(TextField gsbsBankAccount) {
        this.gsbsBankAccount = gsbsBankAccount;
    }

    public void setAddBtn(Button addBtn) {
        this.addBtn = addBtn;
    }

    public void setPayingBankController(PayingBankController payingBankController) {
        this.payingBankController = payingBankController;
    }

    public boolean equals(Object o) {
        if (o == this) {
            return true;
        }
        if (!(o instanceof EditBankInfoController)) {
            return false;
        }
        EditBankInfoController other = (EditBankInfoController)o;
        if (!other.canEqual(this)) {
            return false;
        }
        TextField this$gsbsBankId = this.getGsbsBankId();
        TextField other$gsbsBankId = other.getGsbsBankId();
        if (this$gsbsBankId == null ? other$gsbsBankId != null : !this$gsbsBankId.equals(other$gsbsBankId)) {
            return false;
        }
        Button this$editBtn = this.getEditBtn();
        Button other$editBtn = other.getEditBtn();
        if (this$editBtn == null ? other$editBtn != null : !this$editBtn.equals(other$editBtn)) {
            return false;
        }
        Pane this$modelPane = this.getModelPane();
        Pane other$modelPane = other.getModelPane();
        if (this$modelPane == null ? other$modelPane != null : !this$modelPane.equals(other$modelPane)) {
            return false;
        }
        TextField this$gsbsBrId = this.getGsbsBrId();
        TextField other$gsbsBrId = other.getGsbsBrId();
        if (this$gsbsBrId == null ? other$gsbsBrId != null : !this$gsbsBrId.equals(other$gsbsBrId)) {
            return false;
        }
        TextField this$gsbsBankName = this.getGsbsBankName();
        TextField other$gsbsBankName = other.getGsbsBankName();
        if (this$gsbsBankName == null ? other$gsbsBankName != null : !this$gsbsBankName.equals(other$gsbsBankName)) {
            return false;
        }
        TextField this$gsbsBankAccount = this.getGsbsBankAccount();
        TextField other$gsbsBankAccount = other.getGsbsBankAccount();
        if (this$gsbsBankAccount == null ? other$gsbsBankAccount != null : !this$gsbsBankAccount.equals(other$gsbsBankAccount)) {
            return false;
        }
        Button this$addBtn = this.getAddBtn();
        Button other$addBtn = other.getAddBtn();
        if (this$addBtn == null ? other$addBtn != null : !this$addBtn.equals(other$addBtn)) {
            return false;
        }
        PayingBankController this$payingBankController = this.getPayingBankController();
        PayingBankController other$payingBankController = other.getPayingBankController();
        return !(this$payingBankController == null ? other$payingBankController != null : !(this$payingBankController).equals(other$payingBankController));
    }

    protected boolean canEqual(Object other) {
        return other instanceof EditBankInfoController;
    }

    public int hashCode() {
        int PRIME = 59;
        int result = 1;
        TextField $gsbsBankId = this.getGsbsBankId();
        result = result * 59 + ($gsbsBankId == null ? 43 : $gsbsBankId.hashCode());
        Button $editBtn = this.getEditBtn();
        result = result * 59 + ($editBtn == null ? 43 : $editBtn.hashCode());
        Pane $modelPane = this.getModelPane();
        result = result * 59 + ($modelPane == null ? 43 : $modelPane.hashCode());
        TextField $gsbsBrId = this.getGsbsBrId();
        result = result * 59 + ($gsbsBrId == null ? 43 : $gsbsBrId.hashCode());
        TextField $gsbsBankName = this.getGsbsBankName();
        result = result * 59 + ($gsbsBankName == null ? 43 : $gsbsBankName.hashCode());
        TextField $gsbsBankAccount = this.getGsbsBankAccount();
        result = result * 59 + ($gsbsBankAccount == null ? 43 : $gsbsBankAccount.hashCode());
        Button $addBtn = this.getAddBtn();
        result = result * 59 + ($addBtn == null ? 43 : $addBtn.hashCode());
        PayingBankController $payingBankController = this.getPayingBankController();
        result = result * 59 + ($payingBankController == null ? 43 : ($payingBankController).hashCode());
        return result;
    }

    public String toString() {
        return "EditBankInfoController(gsbsBankId=" + this.getGsbsBankId() + ", editBtn=" + this.getEditBtn() + ", modelPane=" + this.getModelPane() + ", gsbsBrId=" + this.getGsbsBrId() + ", gsbsBankName=" + this.getGsbsBankName() + ", gsbsBankAccount=" + this.getGsbsBankAccount() + ", addBtn=" + this.getAddBtn() + ", payingBankController=" + this.getPayingBankController() + ")";
    }
}

